{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑勋章</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <input type="hidden" name="id" value="{$info.id}">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="lb_name" lay-verify="required" value="{$info['name']}" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">描述：</label>
                            <div class="layui-input-block">
                                <input type="text" name="miaoshu" lay-verify="required" value="{$info['miaoshu']}" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                        <label class="layui-form-label">点亮图片上传：</label>
                        <input type="hidden" name="img" id="lay-img" lay-verify="image" value="{$info.thumb_light}">
                        <div class="layui-input-block">
                            <div id="lay-upload">上传图片</div>
                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                预览图：
                                <div class="layui-upload-list" id="lay-list">
                                    <img class="layui-append-img" src="{$info.thumb_light}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                </div>
                            </blockquote>
                        </div>
                    </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">未点亮图片上传：</label>
                            <input type="hidden" name="img1" id="lay-img1" lay-verify="image" value="{$info.thumb}">
                            <div class="layui-input-block">
                                <div id="lay-upload1">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list1">
                                        <img class="layui-append-img" src="{$info.thumb}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8" id="unbooks_id">
                            <label class="layui-form-label">选择优惠券：</label>
                            <div class="layui-input-block">
                                <select name="coupon_id"  xm-select="select1"  xm-select-search="" xm-select-radio="" xm-select-search-type="dl">
                                    <option value="" >请选择</option>
                                    {foreach name="coupon" item="v"}
                                    <option value="{$v.coupon_id}" {$v.coupon_id==$info.coupon_id?'selected':''}>{$v.coupon_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">奖励金币：</label>
                            <div class="layui-input-block">
                                <input type="number" name="exp" lay-verify="required" value="{$info['exp']}" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:"",num:1});
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.verify({
            image:[/\S/,'请上传图片'],
            editor:function(value,item){
                if(editor.txt.html() == '<p><br></p>'){
                    return '请填写内容';
                }
            }
        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('update')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('medal/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>
